package com.baidu.booklib.service.impl;


import com.baidu.booklib.dao.BookDao;
import com.baidu.booklib.domain.Book;
import com.baidu.booklib.service.BookService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookDao bookDao;

    @Override
    public Book selectById(Integer id) {
        return bookDao.selectById(id);
    }

    @Override
    public List<Book> selectAll() {
        /*
        * 以下测试
        * */
//        QueryWrapper queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("name",name);
        /*
        * 以上测试
        * */


        return bookDao.selectList(null);
//        查询的条件为null，意味着查询所有，实现方法
    }

    @Override
    public Boolean insert(Book book) {
        return bookDao.insert(book)>=1;
    }
//    插入记录

}
